#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Environment variables substituted by cmake

export BUILD_DIR=@CMAKE_BINARY_DIR@
export SOURCE_DIR=@CMAKE_SOURCE_DIR@

export SASLPASSWD2=@SASLPASSWD2_EXECUTABLE@
export PYTHON=@PYTHON_EXECUTABLE@

if [[ "@ENABLE_VALGRIND@" == "ON" ]]; then
    export VALGRIND=@VALGRIND_EXECUTABLE@
fi

# Python path

export PYTHONPATH=$BUILD_DIR/src/tests:$BUILD_DIR/bindings/qpid/python:$BUILD_DIR/management/python/lib:${PYTHONPATH-}

# Path

export PATH=$BUILD_DIR/src:$BUILD_DIR/src/tests:$BUILD_DIR/management/python/bin:${PATH-}

# Modules

function export_module {
    if [[ -f $BUILD_DIR/src/$2 ]]; then
	export $1=$BUILD_DIR/src/$2
    fi
}

export_module HA_LIB ha.so
export_module XML_LIB xml.so
export_module AMQP_LIB amqp.so

[[ ${STORE_LIB-} ]] || export_module STORE_LIB linearstore.so
[[ ${STORE_LIB-} ]] || export_module STORE_LIB legacystore.so

export TEST_STORE_LIB=$BUILD_DIR/src/tests/test_store.so

# Qpidd options - Eliminate

export QPID_NO_MODULE_DIR=1	# Don't accidentally load installed modules
export QPID_DATA_DIR=           # Disable persistence
export QPID_CONFIG=$SOURCE_DIR/src/tests/qpidd-empty.conf

# Options for boost test framework

[[ ${BOOST_TEST_SHOW_PROGRESS-} ]] || export BOOST_TEST_SHOW_PROGRESS=yes
[[ ${BOOST_TEST_CATCH_SYSTEM_ERRORS-} ]] || export BOOST_TEST_CATCH_SYSTEM_ERRORS=no

echo "PWD:          $PWD"
echo "SOURCE_DIR:   ${SOURCE_DIR}"
echo "BUILD_DIR:    ${BUILD_DIR}"

echo "PATH:"
echo -n "  "; echo $PATH | sed 's/:/\n  /g'

echo "PYTHONPATH:"
echo -n "  "; echo $PYTHONPATH | sed 's/:/\n  /g'
